import java.util.Scanner;
/**
 * 
 * This program creates a table of Fahrenheit-to-Celsius conversions
 * according to the user's choice of start/end temperatures and the intervals
 * at which results are printed between them.
 * 
 * @author Tara Gallagher
 *
 */

public class HW3 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		double startTempF;
		double endTempF;
		double step;
		
		// Accept table information input.
		System.out.print("Start temperature (degrees F): ");
		startTempF = input.nextDouble();
		System.out.print("End temperature (degrees F): ");
		endTempF = input.nextDouble();
		System.out.print("Step (degrees F): ");
		step = input.nextDouble();
		
		// Make sure the input fits criteria.
		boolean validInput = false;
		while (!validInput) {
			if (endTempF > startTempF) {
				validInput = true;
			}
			if (endTempF - startTempF > step) {
				validInput = true;
			} else {
				System.out
						.println("Error: End temp. must be greater than start temp."
								+ " with at least one step in between.");
				System.exit(1);
			}
		}
		input.close();
		
		// Print table header.
		String f = "Degrees F";
		String c = "Degrees C";
		String header = "__________________";
		System.out.printf("\n%15s %15s\n %s %s\n", f, c, header, header);
		
		// Calculate corresponding temperatures in Celsius.
		for (double tF = startTempF; tF <= endTempF; tF = tF + step) {
			double tC = 5 * (tF - 32) / 9;

			System.out.printf("%15.1f F %15.1f C", tF, tC);
			System.out.println();
		}
	}
}
